{extend name="layout/main" /}

{block name="style"}
<style>
    .stats-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 20px;
        margin-bottom: 30px;
    }
    
    .stat-card {
        background: white;
        padding: 30px;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        text-align: center;
        transition: transform 0.3s, box-shadow 0.3s;
    }
    
    .stat-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    }
    
    .stat-icon {
        font-size: 48px;
        margin-bottom: 15px;
    }
    
    .stat-number {
        font-size: 32px;
        font-weight: bold;
        margin-bottom: 10px;
    }
    
    .stat-label {
        color: #666;
        font-size: 14px;
    }
    
    .system-status {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .status-item {
        display: flex;
        align-items: center;
        padding: 10px;
        background: #f8f9fa;
        border-radius: 4px;
    }
    
    .status-icon {
        margin-right: 10px;
        font-size: 18px;
    }
    
    .quick-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 15px;
        margin-top: 20px;
    }
    
    @media (max-width: 768px) {
        .stats-grid {
            grid-template-columns: 1fr;
        }
    }
</style>
{/block}

{block name="breadcrumb"}
<span class="breadcrumb-item">首页</span>
<span class="breadcrumb-item active">仪表板</span>
{/block}

{block name="content"}
<!-- 统计卡片 -->
<div class="stats-grid">
    <div class="stat-card">
        <div class="stat-icon" style="color: #3498db;">👥</div>
        <div class="stat-number">{$statistics.user_count|default=0}</div>
        <div class="stat-label">用户总数</div>
    </div>
    
    <div class="stat-card">
        <div class="stat-icon" style="color: #2ecc71;">🏪</div>
        <div class="stat-number">{$statistics.merchant_count|default=0}</div>
        <div class="stat-label">商户总数</div>
    </div>
    
    <div class="stat-card">
        <div class="stat-icon" style="color: #f39c12;">⏰</div>
        <div class="stat-number">{$statistics.pending_count|default=0}</div>
        <div class="stat-label">待审核</div>
    </div>
    
    <div class="stat-card">
        <div class="stat-icon" style="color: #27ae60;">✅</div>
        <div class="stat-number">{$statistics.approved_count|default=0}</div>
        <div class="stat-label">已通过</div>
    </div>
    
    <div class="stat-card">
        <div class="stat-icon" style="color: #e74c3c;">❌</div>
        <div class="stat-number">{$statistics.rejected_count|default=0}</div>
        <div class="stat-label">已拒绝</div>
    </div>
</div>

<!-- 系统状态 -->
<div class="content-card mb-20">
    <div class="content-card-header">
        <h3 class="content-card-title">系统状态</h3>
    </div>
    <div class="content-card-body">
        <div class="system-status">
            <div class="status-item">
                <span class="status-icon">✅</span>
                <span>系统运行正常</span>
            </div>
            <div class="status-item">
                <span class="status-icon">✅</span>
                <span>数据库连接正常</span>
            </div>
            <div class="status-item">
                <span class="status-icon">✅</span>
                <span>后台管理系统已就绪</span>
            </div>
        </div>
    </div>
</div>

<!-- 快速操作 -->
<div class="content-card mb-20">
    <div class="content-card-header">
        <h3 class="content-card-title">快速操作</h3>
    </div>
    <div class="content-card-body">
        <div class="quick-actions">
            <a href="/admin/merchant" class="btn">查看商户列表</a>
            <a href="/admin/merchant?status=pending" class="btn btn-warning">待审核商户</a>
            <a href="/admin/log" class="btn btn-success">操作日志</a>
            <a href="/admin/system" class="btn">系统状态</a>
        </div>
    </div>
</div>

<!-- 今日数据 -->
<div class="content-card">
    <div class="content-card-header">
        <h3 class="content-card-title">今日数据</h3>
    </div>
    <div class="content-card-body">
        <div class="stats-grid">
            <div class="stat-card">
                <div class="stat-icon" style="color: #3498db;">📈</div>
                <div class="stat-number">{$today_data.new_users|default=0}</div>
                <div class="stat-label">新增用户</div>
            </div>
            
            <div class="stat-card">
                <div class="stat-icon" style="color: #2ecc71;">📊</div>
                <div class="stat-number">{$today_data.new_merchants|default=0}</div>
                <div class="stat-label">新增商户</div>
            </div>
            
            <div class="stat-card">
                <div class="stat-icon" style="color: #f39c12;">⏳</div>
                <div class="stat-number">{$today_data.pending_today|default=0}</div>
                <div class="stat-label">今日待审核</div>
            </div>
        </div>
    </div>
</div>
{/block}

{block name="script"}
    // 定时刷新统计数据
    setInterval(function() {
        // 这里可以添加AJAX请求来更新统计数据
        console.log('刷新统计数据...');
    }, 30000); // 30秒刷新一次
    
    // 页面加载完成后的初始化
    document.addEventListener('DOMContentLoaded', function() {
        console.log('仪表板加载完成');
    });
{/block}
